/*
Date:20210509 17:04PM
key:注意两个指针走到原链表尾巴要P!=null才换头。
 */
class Solution {
public:
    ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) 
    {
        ListNode *p=headA;
        ListNode *p1=headB;
        while(p!=p1)
        {
            if(p!=NULL)
            {
                p=p->next;
            }
            else
            {
                p=headB;
            }
            if(p1!=NULL)
            {
                p1=p1->next;
            }
            else
            {
                p1=headA;
            }
        }
        //cout<<p->val;
        // if(p==NULL){return NULL;}
        // else{return p;}
        return p;
    }
};